|
|
|
|
|
|
|
' ask user to commit transaction
'
nResult = MsgBox("Transaction Completed. Ready to Commit?",
_vbInformation + vbYesNo, "ProcMonthEnd")
If nResult = vbYes Then
wsUpdate.CommitTrans
MsgBox "Transaction Committed"
Else
wsUpdate.Rollback
MsgBox "Transaction Canceled"
End If
'
nErrFlag = 0
GoTo ProcMonthEndExit
'
ProcMonthEndErr:
MsgBox Trim(Str(Err)) + " " + Error$(Err), vbCritical, "ProcMonthEnd"
nErrFlag = Err
'
ProcMonthEndExit:
'
End Sub |
|
|
|
|
|
|
|
|
This code executes the three SQL statements that perform the updates and deletes needed for the month-end processing. The routine is started with a BeginTrans. When the updates are complete, the user is asked to confirm the transaction. In a production program, you probably wouldn't ask for transaction confirmation; however, this helps you see how the process is working. |
|
|
|
|
|
|
|
|
Finally, you need to add the code that puts everything together. Add the following code to the Form_Load event: |
|
|
|
|
|
|
|
|
Private Sub Form_Load()
OpenDB
If nErrFlag = 0 Then
ProcMonthEnd
End If
'
If nErrFlag <> 0 Then
MsgBox "Error Reported", vbCritical, "FormLoad"
End If
Unload Me
End Sub |
|
|
|
|
|
|
|
|
This routine calls the OpenDB procedure. Then, if no error is reported, it calls the ProcMonthEnd procedure. If an error has occurred during the process, a message is displayed. |
|
|
|
|
|
|
|
|
Save the form as MULTIUS4.FRM and the project as MULTIUS4.VBP, and then run the project. All you'll see is a message that tells you the transaction is complete and asks for your approval. (See Figure 17.10.) |
|
|
|
|
|